package com.xinqing.test.LetCode;

/**
 * @Author:CHQ
 * @Date:2021/7/21 16:42
 * @Description
 */
public class ValidPalindrome {
    public static void main(String args[]){

        String s="adbba";
        int i=0;
        int j=s.length()-1;
        System.out.println(isValid(s,i,j));

    }
    public static boolean isValid(String s,int i,int j){
        while(i<j){
            if(s.charAt(i)!=s.charAt(j)){
                return test(s,++i,j) || test(s,i,--j);
            }
            i++;
            j--;
        }
        return true;
    }
    public static boolean test(String s,int y,int z){
        while(y<z){
            if(s.charAt(y)!=s.charAt(z)){
                return false;
            }
            y++;
            z--;
        }
        return true;
    }
}
